package com.example.yls.demoa;

import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.View;
import android.widget.EditText;

public class AddActivity extends AppCompatActivity{

    private EditText addStuno;
    private EditText addName;
    private EditText addAge;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_add);

        addStuno = findViewById(R.id.addStuno);
        addName = findViewById(R.id.addName);
        addAge = findViewById(R.id.addAge);

        findViewById(R.id.addStu).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                String stuno = addStuno.getText().toString();
                String name = addName.getText().toString();
                int age = Integer.parseInt(addAge.getText().toString());
                Intent intent = new Intent();
                intent.putExtra("STUNO",stuno);
                intent.putExtra("NAME",name);
                intent.putExtra("AGE",age);
                setResult(2001,intent);
                finish();
            }
        });

    }


}
